<template>
	<view>
		<canvas id="mycanvas" canvas-id="mycanvas" @touchmove="touchmove" @touchstart="touchstart"></canvas>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onReady
	} from '@dcloudio/uni-app'
	import {
		ref
	} from 'vue';
	let ctx;
	onReady(() => {
		ctx = uni.createCanvasContext('mycanvas');
		ctx.rect(10, 10, 150, 100);
		ctx.strokeStyle = 'red'
		ctx.stroke();
	})
	const touchstart = (e) => {
		const {
			x,
			y
		} = e.changedTouches[0]
		ctx.beginPath();
		ctx.moveTo(x, y)
		console.log(1)
	}
	const touchmove = (e) => {
		const {
			x,
			y
		} = e.changedTouches[0]
		console.log(x, y)
		ctx.lineTo(x, y)
		ctx.stroke()
		console.log(1)
		ctx.fill()
	}
</script>

<style lang="scss">
	canvas {
		border: 1px solid #ccc;
	}
</style>